package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.pro.domain.entity.StockDateFilterEntity;
import com.xbongbong.saas.domain.dao.StockDateFilterDao;
import com.xbongbong.saas.model.StockDateFilterModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @description: 流水台账筛选偏好配置表
 * @Author: lee
 * @date: 2020-02-27 14:49
 * @since v1.0
 */
@Service("stockDateFilterModel")
public class StockDateFilterModelImpl implements StockDateFilterModel {
    @Resource
    private StockDateFilterDao stockDateFilterDao;

    @Override
    public Integer insert(StockDateFilterEntity entity) throws XbbException {
        long now = DateTimeUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);

        return stockDateFilterDao.insert(entity);
    }

    @Override
    public Integer update(StockDateFilterEntity entity) throws XbbException {
        entity.setUpdateTime(DateTimeUtil.getInt());
        return stockDateFilterDao.update(entity);
    }

    @Override
    public Integer save(StockDateFilterEntity entity) throws XbbException {
        if(entity.getId() == null || entity.getId().equals(0L)) {
            return insert(entity);
        }
        return update(entity);
    }

    @Override
    public List<StockDateFilterEntity> findEntitys(Map<String, Object> param) {
        return stockDateFilterDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return stockDateFilterDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

}
